package com.example.server.util;


//import com.example.server.interceptor.TokenInterceptor;
import com.example.server.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Bean
    public TokenInterceptor TokenInterceptor() {
        return new TokenInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(TokenInterceptor())
                .excludePathPatterns("/user/create")
                .excludePathPatterns("/user/queryByAccountAndPassword")
                .excludePathPatterns("/user/queryById/{id}")
                .excludePathPatterns("/user/queryById")
                .excludePathPatterns("/user/modify")
                .excludePathPatterns("/product/create")
                .excludePathPatterns("/product/queryAll")
                .excludePathPatterns("/product/queryById/{id}")
                .excludePathPatterns("/product/queryBySid")
                .excludePathPatterns("/product/deletes")
                .excludePathPatterns("/product/modify")
                .excludePathPatterns("/product/queryByAccount")
                .excludePathPatterns("/product/*")
                .excludePathPatterns("/history/create")
                .excludePathPatterns("/history/queryByUid")
                .excludePathPatterns("/history/removeById/{id}")
                .excludePathPatterns("/history/removeById")
                .excludePathPatterns("/cart/create")
                .excludePathPatterns("/cart/queryCart")
                .excludePathPatterns("/cart/queryProduct")
                .excludePathPatterns("/cart/modify")
                .excludePathPatterns("/cart/removeById/{id}")
                .excludePathPatterns("/store/queryByAccountAndPassword")
                .excludePathPatterns("/collect/create")
                .excludePathPatterns("/collect/queryByUid")
                .excludePathPatterns("/collect/querySelect")
                .excludePathPatterns("/collect/delete")
                .excludePathPatterns("/collect/delete/{id}")
                .excludePathPatterns("/collect/removeCollect")
                .excludePathPatterns("/coupon/*")
                .excludePathPatterns("/address/**")
                .excludePathPatterns("/order/*")
                .excludePathPatterns("/order/**")
                .excludePathPatterns("/comment/**")
                .excludePathPatterns("/orderList/**")

                .addPathPatterns("/**"); // 拦截路径
    }
}